/**
 * Created by shidaiapp on 2017/9/29.
 */


function changeModelLoading(self, tiyData) {
  tiyData.tStatus.modalClear.isLoading = false;
  self.$nextTick(function () {
    tiyData.tStatus.modalClear.isLoading = true;
  });
}
/**
 * 初始化
 * @param self
 * @param tiyData
 */
export const init = (self, tiyData) => {
  tiyData.tPage.total = 1;
  tiyData.tPage.startIndex = 0;
  tiyData.tPage.stepNumber = 20;
  tiyData.tPage.currentPage = 1;
  tiyData.tParams.searchParams.searchMatchType = "2";
  tiyData.tParams.searchParams.keyWord = "";
  tiyData.tParams.searchParams.startEndDate = [];
  tiyData.tParams.searchParams.isSearchMatched = true;

 };

/**
 * 从服务器请求列表
 * @param self
 * @param tiyData
 * @returns {Array}
 */
export const webList = (self, tiyData) => {
  self.$Spin.show();
  self.$apiUser.unMatchedUser({
    "pageSize": tiyData.tPage.stepNumber,
    "pageNum": tiyData.tPage.currentPage,
    "keyWord":tiyData.tParams.searchParams.keyWord,
    "searchMatchType":tiyData.tParams.searchParams.searchMatchType,
    "startDate": tiyData.tParams.searchParams.startEndDate[0],
    "endDate": tiyData.tParams.searchParams.startEndDate[1],
    "isSearchMatched":tiyData.tParams.searchParams.isSearchMatched
  }, 150).then(function (response) {
    self.$Spin.hide();
    if (response.success) {
      tiyData.tData.userList.length = 0;
      let userPage = response.result;
      tiyData.tPage.total = userPage.total;
      tiyData.tPage.stepNumber = userPage.pageSize;
      userPage.list.forEach(
        function (item) {
          tiyData.tData.userList.push(item);
        }
      );
      if (0 == tiyData.tData.userList.length) {
        tiyData.tData.userList.splice(0,tiyData.tData.userList.length)
      }
    } else {
      self.$Message.error(response.errorMessage);
    }
  });
};

